New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

npm-config-user-agent-parser

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

npm-config-user-agent-parser

Parser for process.env.npm_config_user_agent

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

npm user agent parser

npm and yarn have a user agent string that contains version information. This npm module parses the string into an object that is easily consumed on the command-line or in JavaScript using the Node API.

An example of npm's user agent on a Macbook Pro:

npm/6.1.0 node/v8.9.4 darwin x64

and an example of yarn's on the same machine:

yarn/1.7.0 npm/? node/v8.9.4 darwin x64

Installation

$ npm install npm-config-user-agent-parser

Usage

$ npm-config-user-agent-parser 'yarn/1.7.0 npm/? node/v8.9.4 darwin x64'
yarn    1.7.0
node    8.9.4
platform        darwin
arch    x64
raw     yarn/1.7.0 npm/? node/v8.9.4 darwin x64

Node API

const parser = require('npm-config-user-agent-parser');

const parsed = parser(process.env.npm_config_user_agent);

console.log(parsed);

Outputs:

{
  "yarn": {
    "raw": "1.7.0",
    "major": 1,
    "minor": 7,
    "patch": 0,
    "prerelease": [],
    "build": [],
    "version": "1.7.0"
  },
  "npm": null,
  "node": {
    "raw": "8.9.4",
    "major": 8,
    "minor": 9,
    "patch": 4,
    "prerelease": [],
    "build": [],
    "version": "8.9.4"
  },
  "platform": "darwin",
  "arch": "x64",
  "raw": "yarn/1.7.0 npm/? node/v8.9.4 darwin x64"
}

Keywords

FAQs

Package last updated on 07 Jul 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc